package wetalk.software.bupt.com.wetalk.model.po;

import android.content.Context;

import java.io.Serializable;

import wetalk.software.bupt.com.wetalk.util.SharePreferenceUtil;

/**
 * Created by ww on 2017/12/2.
 */

public class User implements Serializable{
    private String userID;
    private String userName;
    private String password;
    private String avatar;
    private String department;
    private String phone;
    private String email;
    private int userHeader;


    public User(){
    }
    public User(String userid,String username,String password,String avatar,String department
            ,String phone,String email){
        this.userID = userid;
        this.userName = username;
        this.password = password;
        this.avatar = avatar;
        this.department=department;
        this.phone = phone;
        this.email = email;
    }



    public User(String userName, String department, String phone, String email, int userHeader) {
        this.userName = userName;
        this.department=department;
        this.phone = phone;
        this.email = email;
        this.userHeader = userHeader;
    }

    /*public User(String username, String password){
        this.userName = username;
        this.password = password;
    }*/

    public User(String userID, String userName){
        this.userName = userName;
        this.userID = userID;
        this.department="";
        this.phone = "";
        this.email = "";
        this.userHeader = 0;
    }

    public User(String username, int userHeader) {
        this.userName = username;
        this.userHeader = userHeader;
    }

    public int getUserHeader() {
        return userHeader;
    }

    public void setUserHeader(int userHeader) {
        this.userHeader = userHeader;
    }

    public String getUserID() {
        return userID;
    }

    public void setUserId(String userid) {
        this.userID = userid;
    }

    public String getUserName() {
        return userName;
    }

    public void setUserName(String userName) {
        this.userName = userName;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public String getAvatar() {
        return avatar;
    }

    public void setAvatar(String avatar) {
        this.avatar = avatar;
    }

    public String getDepartment() {
        return department;
    }

    public void setDepartment(String department) {
        this.department = department;
    }

    public String getPhone() {
        return phone;
    }

    public void setPhone(String phone) {
        this.phone = phone;
    }

    public String getEmail() {
        return email;
    }

    public void setEmail(String email) {
        this.email = email;
    }

    @Override
    public String toString() {
        final StringBuffer sb = new StringBuffer("User{");
        sb.append("userID=").append(userID);
        sb.append(", userName='").append(userName).append('\'');
        sb.append(", password='").append(password).append('\'');
        sb.append(", avatar='").append(avatar).append('\'');
        sb.append(", department=").append(department);
        sb.append(", phone='").append(phone).append('\'');
        sb.append(", email='").append(email).append('\'');
        sb.append(", userHeader=").append(userHeader);
        sb.append('}');
        return sb.toString();
    }

    public static ChatUser getCurrentUser(Context context) {
        //TODO 需要返回当前用户,使用Sp来做
        SharePreferenceUtil sharePreferenceUtil=new SharePreferenceUtil(context,"WeTalk_SP");
        User user= (User) sharePreferenceUtil.readObject("user");
        ChatUser chatUser=new ChatUser(user.getUserID(),user.getUserName(),user.getPassword(),user.getAvatar(),
                user.getDepartment(),user.getPhone(),user.getEmail());
        return chatUser;
    }


}

